//
//  YKTextField.m
//  baisi
//
//  Created by 吴高烽 on 16/9/28.
//  Copyright © 2016年 吴高烽. All rights reserved.
//

#import "YKTextField.h"
#import <objc/runtime.h>
static NSString *const YKTextfieldPlacholderColorKeyPath = @"_placeholderLabel.textColor";

@implementation YKTextField

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
//+ (void)initialize{
//    unsigned int count = 0;
//    objc_property_t *properties = class_copyPropertyList([UITextView class], &count);
//    for (int i= 0; i<count; i++) {
//        objc_property_t propety = properties[i];
//        YKLog(@"%s-%s",property_getName(propety),property_getAttributes(propety));
//    }
//    free(properties);
//
//}
-(void)awakeFromNib{
    [super awakeFromNib];
//    UILabel *placeholdeLabel = [self valueForKeyPath:@"_placeholderLabel"];
//    placeholdeLabel.textColor = [UIColor redColor];
    [self setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    self.tintColor = self.textColor ;
}
-(void)setHeight:(CGFloat)height{
// 聚焦时 = 高亮
}
// 聚焦
-(BOOL)becomeFirstResponder{
    [self setValue:self.textColor forKeyPath:YKTextfieldPlacholderColorKeyPath];
    return  [super becomeFirstResponder];
}
//失去焦点
-(BOOL)resignFirstResponder{
    [self setValue:[UIColor grayColor] forKeyPath:YKTextfieldPlacholderColorKeyPath];
    return  [super resignFirstResponder ];
}
-(void)setPlaceholdColor:(UIColor *)placeholdColor{
    _placeholdColor = placeholdColor ;
       [self setValue:placeholdColor forKeyPath:YKTextfieldPlacholderColorKeyPath];
}

//-(void)drawPlaceholderInRect:(CGRect)rect{
//    [self.placeholder drawInRect:CGRectMake(0, 13, rect.size.width, 25) withAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[self font]}];
//
//}
/*
  _drawsDebugBaselines-TB,N,S_setDrawsDebugBaselines:
  hash-TQ,R
  superclass-T#,R
  description-T@"NSString",R,C
  debugDescription-T@"NSString",R,C
  delegate-T@"<UITextViewDelegate>",W,D,N
  text-T@"NSString",C,N
  font-T@"UIFont",&,N
  textColor-T@"UIColor",&,N
  textAlignment-Tq,N
  selectedRange-T{_NSRange=QQ},N
  editable-TB,N,GisEditable
  selectable-TB,N,GisSelectable
  dataDetectorTypes-TQ,N
  allowsEditingTextAttributes-TB,N
  attributedText-T@"NSAttributedString",C
  typingAttributes-T@"NSDictionary",C,N
  inputView-T@"UIView",&,V_inputView
  inputAccessoryView-T@"UIView",&
  clearsOnInsertion-TB,N,V_clearsOnInsertion
  textContainer-T@"NSTextContainer",R,N,V_textContainer
  textContainerInset-T{UIEdgeInsets=dddd},N
  layoutManager-T@"NSLayoutManager",R,N,V_layoutManager
  textStorage-T@"NSTextStorage",R,N,V_textStorage
  linkTextAttributes-T@"NSDictionary",C,N
  hash-TQ,R
  superclass-T#,R
  description-T@"NSString",R,C
  debugDescription-T@"NSString",R,C
  autocapitalizationType-Tq,D,N
  autocorrectionType-Tq,D,N
  spellCheckingType-Tq,D,N
  keyboardType-Tq,D,N
  keyboardAppearance-Tq,D,N
  returnKeyType-Tq,D,N
  enablesReturnKeyAutomatically-TB,D,N
  secureTextEntry-TB,D,N,GisSecureTextEntry
  textContentType-T@"NSString",C,N
  recentInputIdentifier-T@"NSString",C,N
  validTextRange-T{_NSRange=QQ},N
  PINEntrySeparatorIndexes-T@"NSIndexSet",C,N
  textTrimmingSet-T^{__CFCharacterSet=},N
  insertionPointColor-T@"UIColor",&,N
  selectionBarColor-T@"UIColor",&,N
  selectionHighlightColor-T@"UIColor",&,N
  selectionDragDotImage-T@"UIImage",&,N
  insertionPointWidth-TQ,N
  textLoupeVisibility-Ti,N
  textSelectionBehavior-Ti,N
  textSuggestionDelegate-T@,N
  isSingleLineDocument-TB,N
  contentsIsSingleValue-TB,N
  hasDefaultContents-TB,N
  acceptsEmoji-TB,N
  acceptsDictationSearchResults-TB,N
  forceEnableDictation-TB,N
  forceDisableDictation-TB,N
  forceDefaultDictationInfo-TB,N
  forceDictationKeyboardType-Tq,N
  emptyContentReturnKeyType-Ti,N
  returnKeyGoesToNextResponder-TB,N
  acceptsFloatingKeyboard-TB,N
  acceptsSplitKeyboard-TB,N
  displaySecureTextUsingPlainText-TB,N
  displaySecureEditsUsingPlainText-TB,N
  learnsCorrections-TB,N
  shortcutConversionType-Ti,N
  suppressReturnKeyStyling-TB,N
  useInterfaceLanguageForLocalization-TB,N
  deferBecomingResponder-TB,N
  enablesReturnKeyOnNonWhiteSpaceContent-TB,N
  autocorrectionContext-T@"NSString",C,N
  responseContext-T@"NSString",C,N
  inputContextHistory-T@"UIInputContextHistory",&,N
  disablePrediction-TB,N
  disableInputBars-TB,N
  isCarPlayIdiom-TB,N
  textScriptType-Tq,N
  hasText-TB,R,N
  selectedTextRange-T@"UITextRange",C
  markedTextRange-T@"UITextRange",R,N
  markedTextStyle-T@"NSDictionary",C,N
  beginningOfDocument-T@"UITextPosition",R,N
  endOfDocument-T@"UITextPosition",R,N
  inputDelegate-T@"<UITextInputDelegate>",W,N
  tokenizer-T@"<UITextInputTokenizer>",R,N
  textInputView-T@"UIView",R,N
  selectionAffinity-Tq,N
  insertDictationResultPlaceholder-T@,R,N
  adjustsFontForContentSizeCategory-TB,N,V_adjustsFontForContentSizeCategory
 */
@end
